function LastRemaining_Solution(n, m)
{
    // write code here
    if(n === 0) return 0
    let x = 0
    for(let i = 1;i < n;i++){
      x = (x + m) % (i + 1)
    }
    return x
}
module.exports = {
    LastRemaining_Solution : LastRemaining_Solution
};